<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>MiXiM: D:/Projects/MiXiM/extsrc/mixim/src/modules/power/battery/SimpleBattery.h Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">MiXiM
   &#160;<span id="projectnumber">2.3</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('a00487.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">SimpleBattery.h</div>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* -*- mode:c++ -*- ********************************************************</span>
<a name="l00002"></a>00002 <span class="comment"> * Energy Framework for Omnet++, version 0.9</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> * Author:  Laura Marie Feeney</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * Copyright 2009 Swedish Institute of Computer Science.</span>
<a name="l00007"></a>00007 <span class="comment"> *</span>
<a name="l00008"></a>00008 <span class="comment"> * This software is provided `as is&#39; and without any express or implied</span>
<a name="l00009"></a>00009 <span class="comment"> * warranties, including, but not limited to, the implied warranties of</span>
<a name="l00010"></a>00010 <span class="comment"> * merchantability and fitness for a particular purpose.</span>
<a name="l00011"></a>00011 <span class="comment"> *</span>
<a name="l00012"></a>00012 <span class="comment"> ***************************************************************************/</span>
<a name="l00013"></a>00013 <span class="preprocessor">#ifndef BATTERY_H</span>
<a name="l00014"></a>00014 <span class="preprocessor"></span><span class="preprocessor">#define BATTERY_H</span>
<a name="l00015"></a>00015 <span class="preprocessor"></span>
<a name="l00016"></a>00016 <span class="preprocessor">#include &lt;omnetpp.h&gt;</span>
<a name="l00017"></a>00017 
<a name="l00018"></a>00018 <span class="preprocessor">#include &quot;MiXiMDefs.h&quot;</span>
<a name="l00019"></a>00019 <span class="preprocessor">#include &quot;BaseBattery.h&quot;</span>
<a name="l00020"></a>00020 
<a name="l00021"></a>00021 <span class="preprocessor">#include &quot;BatteryState.h&quot;</span>
<a name="l00022"></a>00022 <span class="preprocessor">#include &quot;HostState.h&quot;</span>
<a name="l00023"></a>00023 
<a name="l00024"></a>00024 <span class="preprocessor">#include &quot;DeviceEntry.h&quot;</span>
<a name="l00025"></a>00025 
<a name="l00041"></a><a class="code" href="a00193.html">00041</a> <span class="keyword">class </span>MIXIM_API <a class="code" href="a00193.html" title="A simple linear model of battery consumption.">SimpleBattery</a>: <span class="keyword">public</span> <a class="code" href="a00018.html" title="Base class for any power source.">BaseBattery</a> {
<a name="l00042"></a>00042 <span class="keyword">private</span>:
<a name="l00045"></a>00045   <a class="code" href="a00193.html" title="A simple linear model of battery consumption.">SimpleBattery</a>(<span class="keyword">const</span> <a class="code" href="a00193.html" title="A simple linear model of battery consumption.">SimpleBattery</a>&amp;);
<a name="l00048"></a>00048   <a class="code" href="a00193.html" title="A simple linear model of battery consumption.">SimpleBattery</a>&amp; <a class="code" href="a00018.html#a19d997709c3c25391b2856d8a54e2810" title="Assignment operator is not allowed.">operator=</a>(<span class="keyword">const</span> <a class="code" href="a00193.html" title="A simple linear model of battery consumption.">SimpleBattery</a>&amp;);
<a name="l00049"></a>00049 
<a name="l00050"></a>00050 <span class="keyword">public</span>:
<a name="l00051"></a>00051   <a class="code" href="a00193.html" title="A simple linear model of battery consumption.">SimpleBattery</a>();
<a name="l00052"></a>00052   <span class="keyword">virtual</span> ~<a class="code" href="a00193.html" title="A simple linear model of battery consumption.">SimpleBattery</a>();
<a name="l00053"></a>00053   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00027.html#a03030e439aaf030c83da6e71e8be2f80" title="Basic initialization for all modules.">initialize</a>(<span class="keywordtype">int</span>);
<a name="l00054"></a>00054   <span class="keyword">virtual</span> <span class="keywordtype">void</span> handleMessage(cMessage*);
<a name="l00055"></a>00055   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00027.html#a44220aa650488eee8ad121f8bc599265" title="Called whenever the hosts state changes.">handleHostState</a>(<span class="keyword">const</span> <a class="code" href="a00098.html" title="HostState is published by the battery to announce host failure.">HostState</a>&amp; state);
<a name="l00056"></a>00056   <span class="keyword">virtual</span> <span class="keywordtype">void</span> finish();
<a name="l00057"></a>00057 
<a name="l00067"></a>00067   <span class="keywordtype">double</span> <a class="code" href="a00018.html#a20ee7721d8da961e3493da63a0fafb81" title="get voltage (future support for non-voltage regulated h/w">getVoltage</a>() <span class="keyword">const</span>;
<a name="l00071"></a>00071   <span class="keywordtype">double</span> <a class="code" href="a00018.html#a67c0d2c69f13b6c7ca4a24b23257d83f" title="current state of charge of the battery, relative to its rated nominal capacity [0..1]">estimateResidualRelative</a>() <span class="keyword">const</span>;
<a name="l00073"></a>00073   <span class="keywordtype">double</span> <a class="code" href="a00018.html#a15862e04dfa8b40082ecccff79b14ca0" title="current state of charge of the battery (mW-s)">estimateResidualAbs</a>() <span class="keyword">const</span>;
<a name="l00079"></a>00079   <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="a00018.html#a6b2ac07e8d11823bdd239de2bfa4563a" title="Registers a power draining device with this battery.">registerDevice</a>(<span class="keyword">const</span> std::string&amp; name, <span class="keywordtype">int</span> numAccounts);
<a name="l00080"></a>00080 
<a name="l00085"></a>00085   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00018.html#a4ac1773aef7363fc880a9689706ccc99" title="Draws power from the battery.">draw</a>(<span class="keywordtype">int</span> drainID, <a class="code" href="a00087.html" title="Defines the amount of power drawn by a device from a power source.">DrawAmount</a>&amp; amount, <span class="keywordtype">int</span> activity);
<a name="l00086"></a>00086 
<a name="l00087"></a><a class="code" href="a00193.html#a3e92cb2ebfbcd0879279f45ac03a5111">00087</a>   <span class="keyword">virtual</span> <a class="code" href="a00098.html#a5002302e0f07bbd982c6e5d65eaa9c3c" title="Possible host states.">HostState::States</a> <a class="code" href="a00193.html#a3e92cb2ebfbcd0879279f45ac03a5111" title="Current state of the battery.">getState</a>()<span class="keyword"> const </span>{
<a name="l00088"></a>00088     <span class="keywordflow">return</span> hostState.get();
<a name="l00089"></a>00089   }
<a name="l00090"></a>00090 
<a name="l00091"></a>00091 <span class="keyword">protected</span>:
<a name="l00092"></a>00092 
<a name="l00094"></a><a class="code" href="a00193.html#a713465d20e40c275f105d9cdff32b3f3">00094</a>   <span class="keywordtype">int</span> <a class="code" href="a00193.html#a713465d20e40c275f105d9cdff32b3f3" title="The maximum amount of different power drawing devices.">numDevices</a>;
<a name="l00095"></a>00095 
<a name="l00099"></a><a class="code" href="a00193.html#a05d65f8b333b68eec48de0888f68261c">00099</a>   <span class="keywordtype">double</span> <a class="code" href="a00193.html#a05d65f8b333b68eec48de0888f68261c" title="Actual capacity.">capmAh</a>;
<a name="l00101"></a><a class="code" href="a00193.html#a318d762eb5c65237eb9aca0bf0e6d880">00101</a>   <span class="keywordtype">double</span> <a class="code" href="a00193.html#a318d762eb5c65237eb9aca0bf0e6d880" title="Nominal capacity.">nominalCapmAh</a>;
<a name="l00103"></a><a class="code" href="a00193.html#aac296663af4d156e5b31f868abb5f7b7">00103</a>   <span class="keywordtype">double</span> <a class="code" href="a00193.html#aac296663af4d156e5b31f868abb5f7b7" title="Voltage.">voltage</a>;
<a name="l00107"></a><a class="code" href="a00193.html#adf9aa194bb0405e0d1d504a2f4e2562a">00107</a>   simtime_t <a class="code" href="a00193.html#adf9aa194bb0405e0d1d504a2f4e2562a" title="Debit battery at least once every resolution seconds.">resolution</a>;
<a name="l00108"></a>00108   cMessage *timeout;
<a name="l00109"></a>00109 
<a name="l00112"></a>00112   cMessage *publish;
<a name="l00113"></a>00113   <span class="keywordtype">double</span> publishDelta;
<a name="l00114"></a>00114   simtime_t publishTime;
<a name="l00115"></a>00115 
<a name="l00117"></a><a class="code" href="a00193.html#ad65a4502e96576b1e12332dbb19a1f3e">00117</a>   <a class="code" href="a00032.html" title="residual capacity of battery">BatteryState</a> *<a class="code" href="a00193.html#ad65a4502e96576b1e12332dbb19a1f3e" title="Holds the state of the battery.">batteryState</a>;
<a name="l00123"></a>00123   <a class="code" href="a00098.html" title="HostState is published by the battery to announce host failure.">HostState</a> hostState;
<a name="l00128"></a>00128   <span class="keywordtype">double</span> capacity;
<a name="l00129"></a>00129   <span class="keywordtype">double</span> nominalCapacity;
<a name="l00130"></a>00130   <span class="keywordtype">double</span> residualCapacity;
<a name="l00131"></a>00131   <span class="keywordtype">double</span> lastPublishCapacity;
<a name="l00132"></a>00132   simtime_t lifetime;
<a name="l00136"></a><a class="code" href="a00193.html#a7ac70c949d5974651eb5c669f10352d9">00136</a>   cOutVector <a class="code" href="a00193.html#a7ac70c949d5974651eb5c669f10352d9" title="Ouput vector tracking the residual capacity.">residualVec</a>;
<a name="l00137"></a>00137 
<a name="l00139"></a><a class="code" href="a00193.html#a1667f1336167e09b40dc3ab3b94f05d9">00139</a>   <a class="code" href="a00084.html" title="per-device/per-account record of battery consumption, is passed to BatteryStats on finish()...">DeviceEntry</a> *<a class="code" href="a00193.html#a1667f1336167e09b40dc3ab3b94f05d9" title="Array of different power consuming devices.">devices</a>;
<a name="l00141"></a><a class="code" href="a00193.html#aca990f2e71c484694cb93bf2fe5cf29c">00141</a>   <span class="keywordtype">int</span> <a class="code" href="a00193.html#aca990f2e71c484694cb93bf2fe5cf29c" title="Amount of currently registered devices.">registeredDevices</a>;
<a name="l00142"></a>00142 
<a name="l00144"></a><a class="code" href="a00193.html#a2027a9cfdf410e246a3cb90acbfad6dd">00144</a>   <span class="keyword">enum</span> <a class="code" href="a00193.html#a2027a9cfdf410e246a3cb90acbfad6dd" title="Self message kinds used by the battery.">msgType</a> {
<a name="l00145"></a>00145     AUTO_UPDATE,
<a name="l00146"></a>00146     PUBLISH,
<a name="l00147"></a>00147   };
<a name="l00148"></a>00148 
<a name="l00149"></a>00149   simtime_t lastUpdateTime;
<a name="l00151"></a><a class="code" href="a00193.html#a31ed3863dd9803577d59dfa8952b1d72">00151</a>   cModule*  <a class="code" href="a00193.html#a31ed3863dd9803577d59dfa8952b1d72" title="Pointer to host module.">host</a>;
<a name="l00152"></a>00152   <span class="keyword">virtual</span> <span class="keywordtype">void</span> deductAndCheck();
<a name="l00153"></a>00153 };
<a name="l00154"></a>00154 
<a name="l00155"></a>00155 <span class="preprocessor">#endif</span>
</pre></div></div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><b>SimpleBattery.h</b>      </li>

    <li class="footer">Generated on Tue Mar 5 2013 21:26:30 for MiXiM by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
